<template>
  <ant-modal modalWidth="1000" modalHeight="600" :visible="open" :modal-title="formTitle" :adjust-size="true"
    @cancel="cancel">
    <a-form-model ref="form" :model="form" :rules="rules" slot="content" layout="vertical">
      <a-row :gutter="32">
        <a-col :span="12">
          <a-form-model-item label="收支单号">
            <a-input v-model="form.payCode" placeholder="单号自动生成" :disabled='true' />
          </a-form-model-item>
        </a-col>
        
        <a-col :span="12">
          <a-form-model-item label="往来单位">
            <a-select
              :disabled="form.auditStatus > 1"
              placeholder="请选择往来单位"
              v-model="form.customerId"
              :getPopupContainer="
                triggerNode => {
                  return triggerNode.parentNode || document.body
                }
              "
              style="width: 100%"
              allow-clear
              show-search
              optionFilterProp="children"
            >
              <a-select-option v-for="(d, index) in customerIdOptions" :key="index" :value="d.id">{{ d.customerName }}</a-select-option>
            </a-select>
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="金额">
            <a-input v-model="form.payAmount"  placeholder="请输入金额" disabled  readOnly/>
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="收款日期" prop="payDate">
            <a-date-picker v-model="form.payDate" valueFormat="YYYY-MM-DD" :show-today="true" placeholder="选择日期"
              style="width: 100%" />
          </a-form-model-item>
        </a-col>
        
        <a-col :span="12">
          <a-form-model-item label="费用类型" prop="costType">
            <a-radio-group v-model="form.costType" button-style="solid">
                  <a-radio-button
                    v-for="(dict, index) in inOutOptions"
                    :key="index"
                    :value="dict.dictValue"
                  >
                    {{ dict.dictLabel }}
                  </a-radio-button>
                </a-radio-group>
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="备注" prop="remark">
            <a-input v-model="form.remark" placeholder="请输入备注" />
          </a-form-model-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col :span="24">
          <a-card :bordered="false">
            <advance-table :loading="loading" rowKey="id" size="middle" :columns="columns1" :data-source="orderList"
              :row-selection="{ selectedRowKeys: selectedAccountRowKeys, onChange: onAccountSelectChange }"
              :pagination="false" :bordered="true">
              <div class="table-operations" slot="button" style='margin-bottom:0px;'>
                  <div class="table_title">账户列表</div>
                  <a-button v-if="!disabled && (form.status === '0' || !form.id)" type="primary" @click="handleAdd"  >
                    <a-icon type="plus" />新增
                  </a-button>
                  <a-button type="danger" v-if="multipleAccount && form.status === '0'" @click="handleDelete">
                    <a-icon type="delete" />删除
                  </a-button>
                </div>
              <span slot="payAccount" slot-scope="{record}">
                <a-select placeholder="请选择收款账户" v-model="record.payAccount" style="width: 100%" allow-clear>
                  <a-select-option v-for="(d, index) in payOptions" :key="index" :value="d.dictLabel">{{ d.dictLabel }}</a-select-option>
                </a-select>
              </span>
              <span slot="payAmount" slot-scope="{record}">
                <a-input type='text' placeholder="请输入收款金额" v-model="record.payAmount" @change="amountChange"/>
              </span>
              <span slot="remark" slot-scope="{record}">
                <a-input type='text' placeholder="请输入备注" v-model="record.remark" />
              </span>
            </advance-table>
          </a-card>
        </a-col>
      </a-row>
    </a-form-model>
    <template slot="footer">
      <a-button :disabled="disabled" @click="cancel">
        取消
      </a-button>
      <a-button type="primary" v-if="form.status === '0' || !form.id" :disabled="disabled" @click="submitForm(true)" v-hasPermi="['biz:bizCost:add']">
        保存
      </a-button>
    </template>
  </ant-modal>
</template>
<script>
import BizIncomePaymentForm from './BizIncomePaymentForm'
export default {
  ...BizIncomePaymentForm
}
</script>
<style lang="less" scoped>
.table-operations,
body tr.ant-table-expanded-row:hover .table-operations {
  padding-bottom: 8px;
  text-align: right;
}

.table-operations {
  margin-bottom: 16px;
}

.table-operations>button,
.table-operations .ant-input-affix-wrapper {
  margin-right: 8px;
}

.table_title {
  float: left;
  padding-left: 8px;
  font-weight: 600;
  color: #222222;
  line-height: 30px;
}
</style>
